//
//  headProductView.m
//  代理端
//
//  Created by mac on 16/3/8.
//  Copyright © 2016年 sliver. All rights reserved.
//

#import "headProductView.h"
@interface headProductView()

@property (weak, nonatomic) IBOutlet UIImageView *iconImage;
@property (weak, nonatomic) IBOutlet UILabel *nameLbale;
@property (weak, nonatomic) IBOutlet UILabel *typedefLable;
@property (weak, nonatomic) IBOutlet UILabel *priceLable;
@property (weak, nonatomic) IBOutlet UILabel *countLbale;
@property (weak, nonatomic) IBOutlet UILabel *moneyLable;
@property (weak, nonatomic) IBOutlet UIView *lineLable;

@end
@implementation headProductView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)awakeFromNib
{
    self.iconImage.layer.masksToBounds = YES;
    
    self.iconImage.layer.cornerRadius = 5;
    [AutoLayoutUtil autoLayoutWith:self.subviews];
}
-(void)gaveMeModel:(OrderDetailModel *)model
{
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",BASE_URL,model.img_thum_cover]];
    
    [self.iconImage setImageWithURL:url placeholderImage:[UIImage imageNamed:@"代理商信息头像_150.png"]];
    
    self.nameLbale.text = model.commodity_name;
    
    NSArray *array = [model.selected_options JSONValue];
    NSMutableString *sting =nil;
    for (NSInteger i = 0; i<array.count; i++) {
        NSDictionary *dic = array[i];
        NSString *name = dic[@"name"];
        NSString *valuee= dic[@"value"];
        if (i==0) {
            sting = [NSMutableString stringWithFormat:@"%@:%@",name,valuee];
        }else{
            [sting appendFormat:@"    %@:%@",name,valuee];
        }
        self.typedefLable.text = sting;
    }
    self.priceLable.text = [NSString stringWithFormat:@"¥%@",model.univalent];
    
    
    //
    self.countLbale.text = [NSString stringWithFormat:@"共:%@件商品",model.count];
    //
    self.moneyLable.text = [NSString stringWithFormat:@"合计:%.2f",[model.univalent doubleValue]* [model.count
                                                                                                 doubleValue]];
    

}
@end
